//
//  Log.h
//  sad
//
//  Created by Christopher Kemsley on 2/5/12.
//  Copyright (c) 2012 iAppolopolis. All rights reserved.
//

#ifndef sad_Log_h
#define sad_Log_h

#include <sstream>
#include "URL.hpp"
#include "Exception.hpp"
#include "Settings.hpp"

NamespaceBegin






// Internal type
struct	LogSettings ;




class	Log
{
public:
	static void	loadConfiguration	( URL & path ) ;
	
	static void	setShowsErrors		( bool value = true ) ;
	static void	setShowsWarnings	( bool value = true ) ;
	static void	setShowsNotices		( bool value = true ) ;
	static void	setShowsStates		( bool value = true ) ;
	
	static Log&	error	( char const* domain = "sadApp" ) ;
	static Log&	warning	( char const* domain = "sadApp" ) ;
	static Log&	notice	( char const* domain = "sadApp" ) ;
	static Log&	states	( char const* domain = "sadApp" ) ;
	static Log&	output	() ;
	
	static void	flush () ;
	
	static void	logException	( Exception const& exception ) ;
	
	
	template <typename Type>
	Log&	operator <<		( Type const & value )
		{
		if ( mCurrent != 0 )
			(*mCurrent) << value ;
		return *this ;
		}
	
	
private:
	static Log&	shared () ;
	
	Log () ;
	
	std::ostream*	mCurrent ;
	
	static LogSettings&	settings() ;
} ;




NamespaceEnd

#endif
